package com.example.demo.component;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-05-10
 * Time: 9:20
 */
@Component
@RestController
public class ConfigComponent {

    @Value("${person.name}")
    private String username;

    @Value("${person.age}")
    private int age;

    @RequestMapping("/getPerson")
    public String getPerson() {
        return "name: " + username + " age:" + age;
    }

    // 必须加 ${} 否则就是将 Java 赋值给 config
    @Value("")
    private String config;

    @RequestMapping("/say")
    public String say() {
        return config;
    }


}


// 此处的 @Value 是 lombok 下的